package com.hospital.user.registration.controller;

import com.alibaba.fastjson.JSON;
import com.hospital.user.registration.entity.Consumeinfo;
import com.hospital.user.registration.entity.Doctor_queue;
import com.hospital.user.registration.entity.User_orderinfo;
import com.hospital.user.registration.service.InsertGuahaoI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class InsertGuaController {

    @Autowired
    private InsertGuahaoI guahaoI;

    /**
     * 挂号
     *
     * @param patientId   诊卡 例：60004
     * @param patientName 患者姓名
     * @param doctorId    医生id
     * @param time        时间
     * @return true  挂号成功
     */
    @RequestMapping("/gua")
    @ResponseBody
    public String InsertGua(String patientId, String patientName, String doctorId, String time) {
        Doctor_queue queue = new Doctor_queue(patientId, patientName, doctorId, time);
        Consumeinfo consumeinfo = new Consumeinfo(patientId, time);
        User_orderinfo orderinfo = new User_orderinfo(patientId, doctorId, time);
        boolean b1 = guahaoI.insertFei(consumeinfo);
        boolean b2 = guahaoI.insertWei(orderinfo);
        boolean b = false;
        if (b1 && b2) {
            b = guahaoI.insertGua(queue);
        }
        return JSON.toJSONString(b);
    }

}
